package com.one.apartmentsystem.app.controller;

import com.one.apartmentsystem.app.service.ApartmentInfoService;
import com.one.apartmentsystem.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 公寓信息接口
 * @author mpk
 * @since 2024/8/4 11:50:47
 */
@RestController
@RequestMapping("/app/apartment")
@CrossOrigin
@Slf4j
public class ApartmentController {

    public ApartmentController()
    {
        log.info("我被构建了！！");
    }
    /**
     * 注入的公寓信息服务，用于获取公寓信息的业务逻辑
     */
    @Autowired
    ApartmentInfoService apartmentInfoService;

    /**
     * 根据ID获取公寓信息
     * <p>通过GET请求，使用路径变量{@code id}来指定需要查询的公寓ID，返回相应的公寓信息</p>
     *
     * @param id 公寓的ID
     * @return 包含公寓信息的Result对象
     */
    @GetMapping("/{id}")
    public Result getApartment(@PathVariable  String id)
    {
        return Result.ok(apartmentInfoService.getById(id));
    }

}
